package data;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class CreditCard extends AbstractData {
	private long id = -1;
	private transient long hotelId;
	private String CVC;
	private boolean status;
	private String CardType;
	private String NameOnCard;
	private String CardNumber;
	private String ExpiryDate;
	private String Address;
	private String State;
	private String City;
	private String Country;
	private String Zipcode;
	private String Sharer;
	
	public CreditCard()
	{
		status = true;
	}
	
	public CreditCard(long id){
		this.id = id;
		this.status = true;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getHotelId() {
		return hotelId;
	}

	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}

	public String getCVC() {
		return CVC;
	}

	public void setCVC(String cVC) {
		CVC = cVC;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public String getCardType() {
		return CardType;
	}

	public void setCardType(String cardType) {
		CardType = cardType;
	}

	public String getNameOnCard() {
		return NameOnCard;
	}

	public void setNameOnCard(String nameOnCard) {
		NameOnCard = nameOnCard;
	}

	public String getCardNumber() {
		return CardNumber;
	}

	public void setCardNumber(String cardNumber) {
		CardNumber = cardNumber;
	}

	public String getExpiryDate() {
		return ExpiryDate;
	}

	public void setExpiryDate(String expiryDate) {
		ExpiryDate = expiryDate;
	}

	public String getAddress() {
		return Address;
	}

	public void setAddress(String address) {
		Address = address;
	}

	public String getState() {
		return State;
	}

	public void setState(String state) {
		State = state;
	}

	public String getCity() {
		return City;
	}

	public void setCity(String city) {
		City = city;
	}

	public String getZipcode() {
		return Zipcode;
	}

	public void setZipcode(String zipcode) {
		Zipcode = zipcode;
	}

	public String getSharer() {
		return Sharer;
	}

	public void setSharer(String sharer) {
		Sharer = sharer;
	}

	public String getCountry() {
		return Country;
	}

	public void setCountry(String country) {
		Country = country;
	}
	@Override
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.CreditCard);
		else
			item = new Entity(this.key);

		item.setProperty("hotelId", this.hotelId);
		item.setProperty("CVC", this.CVC);
		item.setProperty("status", this.status);
		item.setProperty("CardType", this.CardType);
		item.setProperty("NameOnCard", this.NameOnCard);
		item.setProperty("CardNumber", this.CardNumber);
		item.setProperty("ExpiryDate", this.ExpiryDate);
		item.setProperty("Address", this.Address);
		item.setProperty("State", this.State);
		item.setProperty("City", this.City);
		item.setProperty("Zipcode", this.Zipcode);
		item.setProperty("Country", this.Country);
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("hotelId");
		this.CVC = (String) entity.getProperty("CVC");
		this.CardType = (String) entity.getProperty("CardType");
		this.status = (Boolean) entity.getProperty("status");
		this.NameOnCard = (String) entity.getProperty("NameOnCard");
		this.CardNumber = (String) entity.getProperty("CardNumber");
		this.ExpiryDate = (String) entity.getProperty("ExpiryDate");
		this.Address = (String) entity.getProperty("Address");
		this.State = (String) entity.getProperty("State");
		this.City = (String) entity.getProperty("City");
		this.Zipcode = (String) entity.getProperty("Zipcode");
		this.Country = (String) entity.getProperty("Country");
		this.key = entity.getKey();
	}
	
	public void LoadData()
	{
		if(this.id > -1)
		{
			Entity entity = LoadData(EntityName.CreditCard,this.id);
			setEntity(entity);
		}
	}

}
